/*
 * @Author: fang quan
 * @Date: 2020-06-10 13:38:32 
 * @Last Modified by: fang quan
 * @Last Modified time: 2020-06-10 13:38:32 
 * @Usage webpack配置入口
 */

const TIMESTAMP = new Date().getTime();
const PUBLIC_FILE_NAME = `[name].${process.env.VUE_APP_TYPE}.${TIMESTAMP}`;

// ---- CSS 配置 ----
let css = {
  loaderOptions: {
    sass: {
      data: `@import "@/common/scss/variable.scss";`
    }
  }
};

process.env.VUE_APP_TYPE != "development"
  ? (css.extract = {
      filename: `${PUBLIC_FILE_NAME}.css`,
      chunkFilename: `${PUBLIC_FILE_NAME}.css`
  })
  : null;

module.exports = {
  css,

  devServer: {
    port: 3000,
    disableHostCheck: true,
    proxy: {
      "/api": {
        target: process.env.VUE_APP_API_URL,
        changeOrigin: true,
        pathRewrite: {
          "^/api": "/"
        }
      }
    }
  },

  configureWebpack: {
    output: {
      filename: `${PUBLIC_FILE_NAME}.js`,
      chunkFilename: `${PUBLIC_FILE_NAME}.js`
    }
  },

  publicPath: "youxue/mobile"
}